package com.qingshui.browser.ui.views;

import com.qingshui.browser.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.ImageButton;

public class TabImageButton extends ImageButton {

	private int count;
	public TabImageButton(Context context){
		super(context);
		count = 1;
	}
	public TabImageButton(Context context, AttributeSet attrs) {
		super(context, attrs);
		TypedArray a = context.obtainStyledAttributes(attrs,R.styleable.TabImageButton);
		count=a.getInteger(R.styleable.TabImageButton_count, 1);
		a.recycle();
	}
	
	protected void onDraw (Canvas canvas){
		super.onDraw(canvas);
		Paint paint= new Paint();
		paint.setARGB(255, 119, 131, 155);
		paint.setStyle(Paint.Style.FILL);
		paint.setFakeBoldText(true);
		paint.setStrokeWidth(10);
		paint.setTextAlign(Paint.Align.CENTER);

		paint.setTextSize(22);
		int x=(getRight()-getLeft())/2;
		int y=(getBottom()-getTop())/2;
		//Log.d("dfd", "x "+canvas.getWidth()+" y"+canvas.getHeight()+"  "+String.valueOf(count));
		
		canvas.drawText(String.valueOf(count),x-4, y+12, paint);
		//canvas.drawLine(this.getWidth()/2,0, this.getWidth(), this.getHeight(), paint);
	
	}
	
	public void setCount(int count){
		this.count = count;
		this.postInvalidate();
	}
}